Skip to content

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Aug 3, 2025

Closes phpstan/phpstan#10367

Fix is the first commit 5e252bd

Second commit is just a refacto to reduce the number of method calls 26476e0

Since the method is almost always doing logic like

$type = $this->getOffsetOrProperty(...., false);
if ($type !== null) {
     return type;
} else {
     $type = $this->getOffsetOrProperty(...., true);
     // do things
}

It's better to directly return the type and the certainty and write

[$type, $certainty] = $this->getOffsetOrProperty(...., false);
if ($certainty->yes()) {
     return type;
} else {
     // do things
}

@VincentLanglet VincentLanglet marked this pull request as ready for review August 3, 2025 20:01
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 1efb0ea into phpstan:2.1.x Sep 7, 2025
449 of 454 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

array_column results in non-empty value according to PHPStan

3 participants